package com.gm.wholesale.module.print.model;

import android.util.ArrayMap;

import com.gm.commonlib.base.baseBean.BasePageData;
import com.gm.commonlib.base.baseBean.BaseResp;
import com.gm.commonlib.base.baseBean.DataResp;
import com.gm.commonlib.base.baseView.IBaseView;
import com.gm.commonlib.network.BaseHttpObserver;
import com.gm.commonlib.network.HttpClient;
import com.gm.commonlib.network.HttpServicesHolder;
import com.gm.wholesale.module.print.api.IPrintApi;
import com.gm.wholesale.module.print.bean.PrintParmter;
import com.gm.wholesale.module.print.bean.PrintTemplateBean;

import io.reactivex.Observable;

public class PrintModel {
    public static void setTemplate(IBaseView iBaseView, long id,ArrayMap<String,Object> queryData,
                                   BaseHttpObserver<BaseResp> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IPrintApi, BaseResp>() {
            @Override
            public Observable<BaseResp> getHttpObservable(IPrintApi instance) {
                return instance.setTemplate(id,queryData);
            }
        }, observer);
    }



    //todo 打印订单
    public static void print(IBaseView iBaseView, PrintParmter data,
                                   BaseHttpObserver<BasePageData<String>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IPrintApi, BasePageData<String>>() {
            @Override
            public Observable<BasePageData<String>> getHttpObservable(IPrintApi instance) {
                return instance.print(data);
            }
        }, observer);
    }

    //打印小票
    public static void printReceipt(IBaseView iBaseView, PrintParmter data,
                             BaseHttpObserver<BasePageData<String>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IPrintApi, BasePageData<String>>() {
            @Override
            public Observable<BasePageData<String>> getHttpObservable(IPrintApi instance) {
                return instance.printReceipt(data);
            }
        }, observer);
    }


    public static void getTemplateEnable(IBaseView iBaseView,ArrayMap<String,Object> data,
                             BaseHttpObserver<DataResp<PrintTemplateBean>> observer) {
        HttpClient.sendRequest(iBaseView, new HttpServicesHolder<IPrintApi, DataResp<PrintTemplateBean>>() {
            @Override
            public Observable<DataResp<PrintTemplateBean>> getHttpObservable(IPrintApi instance) {
                return instance.getTemplateEnable(data);
            }
        }, observer);
    }

}
